download latest zig, or if you're from the future, zig 0.11.x

rp2040int:

mkdir rp2040int
cd rp2040int
zig init-exe
cp ../rp2040int.zig src/main.zig
zig build run -- "path-to-firmware.bin"

tested on windows x64 but should work on any platform that zig supports, even if your CPU is big endian or whatever.

note that the emulator needs a list of offsets to correctly run the firmware.
to obtain these offsets you have to open the firmware in a disassembler and find the equivalents.
they're explained in some detail but it would be best to open a firmware that has known offsets to compare the two.
newer firmwares might also have mitigations or do something that slightly breaks the emulator, so keep that in mind.
by default it uses the offsets for one of the dumped firmwares capable of running atmosphere, which was attached to my post.

uf2bin:

if you have a .uf2 and want to make it a .bin you should use another tool. if you're lazy, however, you can use uf2bin, which essentially writes the uf2 contents to a flash buffer and writes the flash buffer to disk.

note that uf2bin won't work on big-endian cpus, if you're using one of those.

like with rp2040int,

mkdir uf2bin
cd uf2bin
zig init-exe
cp ../uf2bin.zig src/main.zig
zig build run -- "path-to-uf2" "path-to-bin-out" 0xbaseofrom 0xsizeofrom

base and size of ROM are based on the rp2040, so pass 0x10000000 and 0x1000000 e.g.

zig build run -- "firm.uf2" "out.bin" 0x10000000 0x1000000
